package com.xintai.system.service.impl;

import java.util.List;

import com.xintai.system.domain.PubWorkshop;
import com.xintai.system.mapper.PubWorkshopMapper;
import com.xintai.system.service.IPubWorkshopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 生产线Service业务层处理
 * 
 * @author xintai
 * @date 2020-12-22
 */
@Service
public class PubWorkshopServiceImpl implements IPubWorkshopService
{
    @Autowired
    private PubWorkshopMapper pubWorkshopMapper;

    /**
     * 查询生产线
     * 
     * @param workshopId 生产线ID
     * @return 生产线
     */
    @Override
    public PubWorkshop selectPubWorkshopById(Long workshopId)
    {
        return pubWorkshopMapper.selectPubWorkshopById(workshopId);
    }

//    @Override
//    public List<PubWorkshop> selectWorkShopPropertyList(Long[] workshopIds, Long[] dictCodeIds) {
//        return null;
//    }

    /**
     * 查询生产线列表
     * 
     * @param pubWorkshop 生产线
     * @return 生产线
     */
    @Override
    public List<PubWorkshop> selectPubWorkshopList(PubWorkshop pubWorkshop)
    {
        return pubWorkshopMapper.selectPubWorkshopList(pubWorkshop);
    }

    /**
     * 新增生产线
     * 
     * @param pubWorkshop 生产线
     * @return 结果
     */
    @Override
    public int insertPubWorkshop(PubWorkshop pubWorkshop)
    {
        if (pubWorkshopMapper.verifyPubWorkshop(pubWorkshop)){
            return -1;
        }
        return pubWorkshopMapper.insertPubWorkshop(pubWorkshop);
    }

    /**
     * 修改生产线
     * 
     * @param pubWorkshop 生产线
     * @return 结果
     */
    @Override
    public int updatePubWorkshop(PubWorkshop pubWorkshop)
    {
        if ( pubWorkshopMapper.verifyPubWorkshop(pubWorkshop) ){
            return -1;
        }
        return pubWorkshopMapper.updatePubWorkshop(pubWorkshop);
    }

    /**
     * 批量删除生产线
     * 
     * @param workshopIds 需要删除的生产线ID
     * @return 结果
     */
    @Override
    public int deletePubWorkshopByIds(Long[] workshopIds)
    {
        return pubWorkshopMapper.deletePubWorkshopByIds(workshopIds);
    }

    /**
     * 删除生产线信息
     * 
     * @param workshopId 生产线ID
     * @return 结果
     */
    @Override
    public int deletePubWorkshopById(Long workshopId)
    {
        return pubWorkshopMapper.deletePubWorkshopById(workshopId);
    }

    /**
     * 验证指定名称是否重复
     * 如果workshop_id 有数据说明是修改，否则是新增，排除已经del的数据（isdel = 1）
     * @param pubWorkshop
     * @return
     */
    @Override
    public boolean verifyPubWorkshop(PubWorkshop pubWorkshop) {
        return pubWorkshopMapper.verifyPubWorkshop(pubWorkshop);
    }
}
